Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add tutorial export_yolo_with_images.py #362

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

makseq
Copy link
Member

@makseq makseq commented Nov 25, 2024

This is a Python script that exports labeled data from a Label Studio project
and converts it into the YOLO format, including downloading associated images.

1. What It Does and How

The script performs the following steps:

  1. Connects to Label Studio: It uses the Label Studio SDK to connect
    to a Label Studio instance using the provided URL and API key.
  2. Retrieves the Project: Fetches the specified project by its ID.
  3. Creates an Export Snapshot: Generates a snapshot of the project's annotations for export.
  4. Downloads Annotations: Downloads the annotations in JSON format.
  5. Converts Annotations to YOLO Format: Utilizes the Label Studio Converter
    to transform the annotations into the YOLO format suitable for object detection tasks.
  6. Downloads Associated Images: Iterates over the exported tasks and downloads the corresponding images,
    implementing retry logic with exponential backoff to handle rate limits or transient network issues.

2. How to Use It

  1. Install Dependencies: Ensure you have Python installed along with the required packages:
    pip install git+https://github.com/heartexlabs/label-studio-sdk.git tqdm
  2. Set Up Credentials: Provide your LABEL_STUDIO_URL, LABEL_STUDIO_API_KEY, and PROJECT_ID either
    by modifying the script variables or via command-line arguments.
  3. Run the Script: Execute the script from the terminal:
    python script.py --url 'https://app.humansignal.com' --api-key 'your-api-key' --project-id 12345
    Replace 'your-api-key' and 12345 with your actual API key and project ID.
  4. Output: The script will create an output_yolo directory containing:
    • YOLO-formatted annotation files.
    • An images subdirectory with all the downloaded images.

3. When to Use It

Use this script when you need to prepare labeled datasets from Label Studio for training YOLO object detection models.
It's particularly useful for converting annotations into the required YOLO format and ensuring all associated images
are downloaded and organized locally for your machine learning pipeline.

@github-actions github-actions bot added the docs label Nov 25, 2024
@makseq makseq merged commit 6113e55 into master Nov 25, 2024
5 checks passed
@makseq makseq deleted the docs-export-yolo-images branch November 25, 2024 22:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant